-------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  \\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Results\setup_equipop
> .log
  log type:  text
 opened on:  29 Jun 2023, 15:11:29

. 
. * Läser in EquiPop-data för ethnic majority 
. foreach year in 2002 2006 2010 {
  2. clear
  3. import delimited using "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\
> From_EquiPop\Above17\ethnic_maj_`year'.dat",  varnames(1)
  4. ren eastwest XKOORD_`year'
  5. ren northsouth YKOORD_`year'
  6. foreach k in 50 100 500 1000 2000{
  7. destring intervalratio_`k', replace dpcomma
  8. ren intervalratio_`k' Ratioethnic_maj_`year'_`k'
  9. destring intervaldistance_`k', replace dpcomma
 10. ren intervaldistance_`k' Distanceethnic_maj_`year'_`k'
 11. }
 12. 
. sort XKOORD_`year' YKOORD_`year'
 13. save "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\ethnic_maj_`y
> ear'_temp.dta", replace
 14. }
(encoding automatically selected: ISO-8859-1)
(30 vars, 234,070 obs)
intervalratio_50: all characters numeric; replaced as double
intervaldistance_50: all characters numeric; replaced as double
intervalratio_100: all characters numeric; replaced as double
intervaldistance_100: all characters numeric; replaced as double
intervalratio_500: all characters numeric; replaced as double
intervaldistance_500: all characters numeric; replaced as double
intervalratio_1000: all characters numeric; replaced as double
intervaldistance_1000: all characters numeric; replaced as double
intervalratio_2000: all characters numeric; replaced as double
intervaldistance_2000: all characters numeric; replaced as double
file \\micro.intra\Projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\ethnic_maj_2002_temp.dta saved
(encoding automatically selected: ISO-8859-1)
(30 vars, 232,150 obs)
intervalratio_50: all characters numeric; replaced as double
intervaldistance_50: all characters numeric; replaced as double
intervalratio_100: all characters numeric; replaced as double
intervaldistance_100: all characters numeric; replaced as double
intervalratio_500: all characters numeric; replaced as double
intervaldistance_500: all characters numeric; replaced as double
intervalratio_1000: all characters numeric; replaced as double
intervaldistance_1000: all characters numeric; replaced as double
intervalratio_2000: all characters numeric; replaced as double
intervaldistance_2000: all characters numeric; replaced as double
file \\micro.intra\Projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\ethnic_maj_2006_temp.dta saved
(encoding automatically selected: ISO-8859-1)
(30 vars, 230,859 obs)
intervalratio_50: all characters numeric; replaced as double
intervaldistance_50: all characters numeric; replaced as double
intervalratio_100: all characters numeric; replaced as double
intervaldistance_100: all characters numeric; replaced as double
intervalratio_500: all characters numeric; replaced as double
intervaldistance_500: all characters numeric; replaced as double
intervalratio_1000: all characters numeric; replaced as double
intervaldistance_1000: all characters numeric; replaced as double
intervalratio_2000: all characters numeric; replaced as double
intervaldistance_2000: all characters numeric; replaced as double
file \\micro.intra\Projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\ethnic_maj_2010_temp.dta saved

. 
. 
. * Analys ethnic majority
. foreach year in 2002 2006 2010 {
  2. clear
  3. use "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\ethnic_maj_`ye
> ar'_temp.dta"
  4. merge 1:m XKOORD_`year' YKOORD_`year' using "\\micro.intra\Projekt\P0624$\P0624_Gem\Po
> litisk Geografi\Data\MergedData\Merged_`year'.dta"
  5. drop _merge
  6. 
. foreach k in 50 100 500 1000 2000{
  7. bysort kommunkod: egen ethnic_maj_`k' = mean(Ratioethnic_maj_`year'_`k')              
>                                           /*Municipality-mean for non-politicians*/
  8. bysort kommunkod: egen ethnic_maj_`k'_pol = mean(Ratioethnic_maj_`year'_`k') if politi
> cian_`year'==1            /*Ditto for politicians*/
  9. bysort kommunkod: gen Ratio_ethnic_maj_`k'= ethnic_maj_`k'_pol/ethnic_maj_`k'
 10. }
 11. collapse Ratio_ethnic_maj_50 Ratio_ethnic_maj_100 Ratio_ethnic_maj_500 Ratio_ethnic_ma
> j_1000 Ratio_ethnic_maj_2000 
 12. gen year = `year'
 13. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_ethni
> c_maj_`year'.dta", replace
 14. }

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         6,981,805  (_merge==3)
    -----------------------------------------
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_ethnic_maj_2002.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,157,824  (_merge==3)
    -----------------------------------------
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_ethnic_maj_2006.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,482,465  (_merge==3)
    -----------------------------------------
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_ethnic_maj_2010.dta saved

. 
. use "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_ethnic_ma
> j_2002.dta", clear

. foreach year in 2006 2010 {
  2. append using "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nho
> od_ethnic_maj_`year'.dta"
  3. }

. 
. collapse Ratio_ethnic_maj_50 Ratio_ethnic_maj_100 Ratio_ethnic_maj_500 Ratio_ethnic_maj_1
> 000 Ratio_ethnic_maj_2000 

. ren Ratio_ethnic_maj_50 Ethnic_majority50

. ren Ratio_ethnic_maj_100 Ethnic_majority100

. ren Ratio_ethnic_maj_500 Ethnic_majority500

. ren Ratio_ethnic_maj_1000 Ethnic_majority1000

. ren Ratio_ethnic_maj_2000 Ethnic_majority2000

. gen id=1

. reshape long Ethnic_majority, i(id) j(k)
(j = 50 100 500 1000 2000)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   5           
Number of variables                   6   ->   3           
j variable (5 values)                     ->   k
xij variables:
Ethnic_majority50 Ethnic_majority100 ... Ethnic_majority2000->Ethnic_majority
-----------------------------------------------------------------------------

. sum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
          id |          5           1           0          1          1
           k |          5         730    805.9156         50       2000
Ethnic_maj~y |          5    1.008447    .0017925   1.005877    1.01009

. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Ethnic_majority.
> dta", replace
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\Ethnic_majority.dta saved

. 
. 
. * Läser in EquiPop-data för high-educated 
. foreach year in 2002 2006 2010 {
  2. clear
  3. import delimited using "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\
> From_EquiPop\Above17\highed_`year'.dat",  varnames(1)
  4. ren eastwest XKOORD_`year'
  5. ren northsouth YKOORD_`year'
  6. foreach k in 50 100 500 1000 2000{
  7. destring intervalratio_`k', replace dpcomma
  8. ren intervalratio_`k' RatioHighed_`year'_`k'
  9. destring intervaldistance_`k', replace dpcomma
 10. ren intervaldistance_`k' Distancehighed_`year'_`k'
 11. }
 12. 
. sort XKOORD_`year' YKOORD_`year'
 13. save "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\highed_`year'
> _temp.dta", replace
 14. }
(encoding automatically selected: ISO-8859-1)
(30 vars, 234,070 obs)
intervalratio_50: all characters numeric; replaced as double
intervaldistance_50: all characters numeric; replaced as double
intervalratio_100: all characters numeric; replaced as double
intervaldistance_100: all characters numeric; replaced as double
intervalratio_500: all characters numeric; replaced as double
intervaldistance_500: all characters numeric; replaced as double
intervalratio_1000: all characters numeric; replaced as double
intervaldistance_1000: all characters numeric; replaced as double
intervalratio_2000: all characters numeric; replaced as double
intervaldistance_2000: all characters numeric; replaced as double
file \\micro.intra\Projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\highed_2002_temp.dta saved
(encoding automatically selected: ISO-8859-1)
(30 vars, 232,150 obs)
intervalratio_50: all characters numeric; replaced as double
intervaldistance_50: all characters numeric; replaced as double
intervalratio_100: all characters numeric; replaced as double
intervaldistance_100: all characters numeric; replaced as double
intervalratio_500: all characters numeric; replaced as double
intervaldistance_500: all characters numeric; replaced as double
intervalratio_1000: all characters numeric; replaced as double
intervaldistance_1000: all characters numeric; replaced as double
intervalratio_2000: all characters numeric; replaced as double
intervaldistance_2000: all characters numeric; replaced as double
file \\micro.intra\Projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\highed_2006_temp.dta saved
(encoding automatically selected: ISO-8859-1)
(30 vars, 230,859 obs)
intervalratio_50: all characters numeric; replaced as double
intervaldistance_50: all characters numeric; replaced as double
intervalratio_100: all characters numeric; replaced as double
intervaldistance_100: all characters numeric; replaced as double
intervalratio_500: all characters numeric; replaced as double
intervaldistance_500: all characters numeric; replaced as double
intervalratio_1000: all characters numeric; replaced as double
intervaldistance_1000: all characters numeric; replaced as double
intervalratio_2000: all characters numeric; replaced as double
intervaldistance_2000: all characters numeric; replaced as double
file \\micro.intra\Projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\highed_2010_temp.dta saved

. 
. 
. 
. * Analys highed
. foreach year in 2002 2006 2010 {
  2. clear
  3. use "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\highed_`year'_
> temp.dta"
  4. merge 1:m XKOORD_`year' YKOORD_`year' using "\\micro.intra\Projekt\P0624$\P0624_Gem\Po
> litisk Geografi\Data\MergedData\Merged_`year'.dta"
  5. drop _merge
  6. 
. foreach k in 50 100 500 1000 2000{
  7. bysort kommunkod: egen Highed_`k' = mean(RatioHighed_`year'_`k')                      
>                                   /*Municipality-mean for non-politicians*/
  8. bysort kommunkod: egen Highed_`k'_pol = mean(RatioHighed_`year'_`k') if politician_`ye
> ar'==1            /*Ditto for politicians*/
  9. bysort kommunkod: gen Ratio_Highed_`k'= Highed_`k'_pol/Highed_`k'
 10. }
 11. collapse Ratio_Highed_50 Ratio_Highed_100 Ratio_Highed_500 Ratio_Highed_1000 Ratio_Hig
> hed_2000 
 12. gen year = `year'
 13. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_educa
> tion_`year'.dta", replace
 14. }

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         6,981,805  (_merge==3)
    -----------------------------------------
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_education_2002.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,157,824  (_merge==3)
    -----------------------------------------
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_education_2006.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,482,465  (_merge==3)
    -----------------------------------------
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_education_2010.dta saved

. 
. use "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_education
> _2002.dta", clear

. foreach year in 2006 2010 {
  2. append using "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nho
> od_education_`year'.dta"
  3. }

. 
. collapse Ratio_Highed_50 Ratio_Highed_100 Ratio_Highed_500 Ratio_Highed_1000 Ratio_Highed
> _2000 

. ren Ratio_Highed_50 Highed50

. ren Ratio_Highed_100 Highed100

. ren Ratio_Highed_500 Highed500

. ren Ratio_Highed_1000 Highed1000

. ren Ratio_Highed_2000 Highed2000

. gen id=1

. reshape long Highed, i(id) j(k)
(j = 50 100 500 1000 2000)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   5           
Number of variables                   6   ->   3           
j variable (5 values)                     ->   k
xij variables:
      Highed50 Highed100 ... Highed2000   ->   Highed
-----------------------------------------------------------------------------

. sum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
          id |          5           1           0          1          1
           k |          5         730    805.9156         50       2000
      Highed |          5     1.03086    .0180813   1.010568   1.054086

. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Highed.dta", rep
> lace
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Highed.dta saved

. 
. 
. * Läser in EquiPop-data för high-earners (highest quartile)
. foreach year in 2002 2006 2010 {
  2. clear
  3. import delimited using "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\
> From_EquiPop\Above17\highq_`year'.dat",  varnames(1)
  4. ren eastwest XKOORD_`year'
  5. ren northsouth YKOORD_`year'
  6. foreach k in 50 100 500 1000 2000{
  7. destring intervalratio_`k', replace dpcomma
  8. ren intervalratio_`k' RatioHighq_`year'_`k'
  9. destring intervaldistance_`k', replace dpcomma
 10. ren intervaldistance_`k' Distancehighq_`year'_`k'
 11. }
 12. 
. sort XKOORD_`year' YKOORD_`year'
 13. save "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\highq_`year'_
> temp.dta", replace
 14. }
(encoding automatically selected: ISO-8859-1)
(30 vars, 234,070 obs)
intervalratio_50: all characters numeric; replaced as double
intervaldistance_50: all characters numeric; replaced as double
intervalratio_100: all characters numeric; replaced as double
intervaldistance_100: all characters numeric; replaced as double
intervalratio_500: all characters numeric; replaced as double
intervaldistance_500: all characters numeric; replaced as double
intervalratio_1000: all characters numeric; replaced as double
intervaldistance_1000: all characters numeric; replaced as double
intervalratio_2000: all characters numeric; replaced as double
intervaldistance_2000: all characters numeric; replaced as double
file \\micro.intra\Projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\highq_2002_temp.dta saved
(encoding automatically selected: ISO-8859-1)
(30 vars, 232,150 obs)
intervalratio_50: all characters numeric; replaced as double
intervaldistance_50: all characters numeric; replaced as double
intervalratio_100: all characters numeric; replaced as double
intervaldistance_100: all characters numeric; replaced as double
intervalratio_500: all characters numeric; replaced as double
intervaldistance_500: all characters numeric; replaced as double
intervalratio_1000: all characters numeric; replaced as double
intervaldistance_1000: all characters numeric; replaced as double
intervalratio_2000: all characters numeric; replaced as double
intervaldistance_2000: all characters numeric; replaced as double
file \\micro.intra\Projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\highq_2006_temp.dta saved
(encoding automatically selected: ISO-8859-1)
(30 vars, 230,859 obs)
intervalratio_50: all characters numeric; replaced as double
intervaldistance_50: all characters numeric; replaced as double
intervalratio_100: all characters numeric; replaced as double
intervaldistance_100: all characters numeric; replaced as double
intervalratio_500: all characters numeric; replaced as double
intervaldistance_500: all characters numeric; replaced as double
intervalratio_1000: all characters numeric; replaced as double
intervaldistance_1000: all characters numeric; replaced as double
intervalratio_2000: all characters numeric; replaced as double
intervaldistance_2000: all characters numeric; replaced as double
file \\micro.intra\Projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\highq_2010_temp.dta saved

. 
. 
. * Analys highq
. foreach year in 2002 2006 2010 {
  2. clear
  3. use "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\highq_`year'_t
> emp.dta"
  4. merge 1:m XKOORD_`year' YKOORD_`year' using "\\micro.intra\Projekt\P0624$\P0624_Gem\Po
> litisk Geografi\Data\MergedData\Merged_`year'.dta"
  5. drop _merge
  6. 
. foreach k in 50 100 500 1000 2000{
  7. bysort kommunkod: egen Highq_`k' = mean(RatioHighq_`year'_`k')                        
>                           /*Municipality-mean for non-politicians*/
  8. bysort kommunkod: egen Highq_`k'_pol = mean(RatioHighq_`year'_`k') if politician_`year
> '==1              /*Ditto for politicians*/
  9. bysort kommunkod: gen Ratio_Highq_`k'= Highq_`k'_pol/Highq_`k'
 10. }
 11. collapse Ratio_Highq_50 Ratio_Highq_100 Ratio_Highq_500 Ratio_Highq_1000 Ratio_Highq_2
> 000 
 12. gen year = `year'
 13. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_dispi
> nc_`year'.dta", replace
 14. }

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         6,981,805  (_merge==3)
    -----------------------------------------
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_dispinc_2002.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,157,824  (_merge==3)
    -----------------------------------------
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_dispinc_2006.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,482,465  (_merge==3)
    -----------------------------------------
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_dispinc_2010.dta saved

. 
. use "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_dispinc_2
> 002.dta", clear

. foreach year in 2006 2010 {
  2. append using "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nho
> od_dispinc_`year'.dta"
  3. }

. 
. collapse Ratio_Highq_50 Ratio_Highq_100 Ratio_Highq_500 Ratio_Highq_1000 Ratio_Highq_2000
>   

. ren Ratio_Highq_50 Highq50

. ren Ratio_Highq_100 Highq100

. ren Ratio_Highq_500 Highq500

. ren Ratio_Highq_1000 Highq1000

. ren Ratio_Highq_2000 Highq2000

. gen id=1

. reshape long Highq, i(id) j(k)
(j = 50 100 500 1000 2000)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   5           
Number of variables                   6   ->   3           
j variable (5 values)                     ->   k
xij variables:
         Highq50 Highq100 ... Highq2000   ->   Highq
-----------------------------------------------------------------------------

. sum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
          id |          5           1           0          1          1
           k |          5         730    805.9156         50       2000
       Highq |          5    1.052854    .0225367   1.025639   1.079826

. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Highq.dta", repl
> ace
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Highq.dta saved

. 
. ******************************
. *All politicians: ADVANTAGE **
. ******************************
. 
. * Analys ethnic majority
. foreach year in 2002 2006 2010 {
  2. clear
  3. use "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\ethnic_maj_`ye
> ar'_temp.dta"
  4. merge 1:m XKOORD_`year' YKOORD_`year' using "\\micro.intra\Projekt\P0624$\P0624_Gem\Po
> litisk Geografi\Data\MergedData\Merged_`year'.dta"
  5. drop _merge
  6. 
. foreach k in 50 100 500 1000 2000{
  7. bysort kommunkod: egen ethnic_maj_`k' = mean(Ratioethnic_maj_`year'_`k')              
>                                           /*Municipality-mean */
  8. bysort kommunkod: egen ethnic_maj_`k'_pol = mean(Ratioethnic_maj_`year'_`k') if politi
> cian_`year'==1                                            /*Ditto for politicians*/
  9. bysort kommunkod: gen Ratio_ethnic_maj_`k'= ethnic_maj_`k'_pol/ethnic_maj_`k'
 10. }
 11. collapse Ratio_ethnic_maj_50 Ratio_ethnic_maj_100 Ratio_ethnic_maj_500 Ratio_ethnic_ma
> j_1000 Ratio_ethnic_maj_2000 
 12. gen year = `year'
 13. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_ethni
> c_maj_all_`year'.dta", replace
 14. }

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         6,981,805  (_merge==3)
    -----------------------------------------
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_ethnic_maj_all_2002.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,157,824  (_merge==3)
    -----------------------------------------
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_ethnic_maj_all_2006.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,482,465  (_merge==3)
    -----------------------------------------
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_ethnic_maj_all_2010.dta saved

. 
. use "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_ethnic_ma
> j_all_2002.dta", clear

. foreach year in 2006 2010 {
  2. append using "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nho
> od_ethnic_maj_all_`year'.dta"
  3. }

. *sum
. *scatter Ratio_ethnic_maj_50 Ratio_ethnic_maj_500 Ratio_ethnic_maj_1000 Ratio_ethnic_maj_
> 2000 year
. *graph export "\\micro.intra\mydocs\mydocs\dahma\my documents\OutBox\k_nearest_ethnic_maj
> .pdf", as(pdf) 
. 
. collapse Ratio_ethnic_maj_50 Ratio_ethnic_maj_100 Ratio_ethnic_maj_500 Ratio_ethnic_maj_1
> 000 Ratio_ethnic_maj_2000 

. ren Ratio_ethnic_maj_50 Ethnic_majority50

. ren Ratio_ethnic_maj_100 Ethnic_majority100

. ren Ratio_ethnic_maj_500 Ethnic_majority500

. ren Ratio_ethnic_maj_1000 Ethnic_majority1000

. ren Ratio_ethnic_maj_2000 Ethnic_majority2000

. gen id=1

. reshape long Ethnic_majority, i(id) j(k)
(j = 50 100 500 1000 2000)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   5           
Number of variables                   6   ->   3           
j variable (5 values)                     ->   k
xij variables:
Ethnic_majority50 Ethnic_majority100 ... Ethnic_majority2000->Ethnic_majority
-----------------------------------------------------------------------------

. sum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
          id |          5           1           0          1          1
           k |          5         730    805.9156         50       2000
Ethnic_maj~y |          5    1.008447    .0017925   1.005877    1.01009

. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Ethnic_majority_
> all.dta", replace
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\Ethnic_majority_all.dta saved

. 
. 
. 
. * Analys highed
. foreach year in 2002 2006 2010 {
  2. clear
  3. use "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\highed_`year'_
> temp.dta"
  4. merge 1:m XKOORD_`year' YKOORD_`year' using "\\micro.intra\Projekt\P0624$\P0624_Gem\Po
> litisk Geografi\Data\MergedData\Merged_`year'.dta"
  5. drop _merge
  6. 
. foreach k in 50 100 500 1000 2000{
  7. bysort kommunkod: egen Highed_`k' = mean(RatioHighed_`year'_`k')                      
>                                   /*Municipality-mean */
  8. bysort kommunkod: egen Highed_`k'_pol = mean(RatioHighed_`year'_`k') if politician_`ye
> ar'==1                                            /*Ditto for politicians*/
  9. bysort kommunkod: gen Ratio_Highed_`k'= Highed_`k'_pol/Highed_`k'
 10. }
 11. collapse Ratio_Highed_50 Ratio_Highed_100 Ratio_Highed_500 Ratio_Highed_1000 Ratio_Hig
> hed_2000 
 12. gen year = `year'
 13. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_educa
> tion_all_`year'.dta", replace
 14. }

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         6,981,805  (_merge==3)
    -----------------------------------------
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_education_all_2002.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,157,824  (_merge==3)
    -----------------------------------------
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_education_all_2006.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,482,465  (_merge==3)
    -----------------------------------------
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_education_all_2010.dta saved

. 
. use "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_education
> _all_2002.dta", clear

. foreach year in 2006 2010 {
  2. append using "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nho
> od_education_all_`year'.dta"
  3. }

. 
. *sum
. *scatter Ratio_Highed_50 Ratio_Highed_500 Ratio_Highed_1000 Ratio_Highed_2000 year
. *graph export "\\micro.intra\mydocs\mydocs\dahma\my documents\OutBox\k_nearest_highed.pdf
> ", as(pdf) 
. collapse Ratio_Highed_50 Ratio_Highed_100 Ratio_Highed_500 Ratio_Highed_1000 Ratio_Highed
> _2000 

. ren Ratio_Highed_50 Highed50

. ren Ratio_Highed_100 Highed100

. ren Ratio_Highed_500 Highed500

. ren Ratio_Highed_1000 Highed1000

. ren Ratio_Highed_2000 Highed2000

. gen id=1

. reshape long Highed, i(id) j(k)
(j = 50 100 500 1000 2000)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   5           
Number of variables                   6   ->   3           
j variable (5 values)                     ->   k
xij variables:
      Highed50 Highed100 ... Highed2000   ->   Highed
-----------------------------------------------------------------------------

. sum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
          id |          5           1           0          1          1
           k |          5         730    805.9156         50       2000
      Highed |          5     1.03086    .0180813   1.010568   1.054086

. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Highed_all.dta",
>  replace
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Highed_all.dta
    saved

. 
. 
. 
. 
. * Analys highq
. foreach year in 2002 2006 2010 {
  2. clear
  3. use "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\highq_`year'_t
> emp.dta"
  4. merge 1:m XKOORD_`year' YKOORD_`year' using "\\micro.intra\Projekt\P0624$\P0624_Gem\Po
> litisk Geografi\Data\MergedData\Merged_`year'.dta"
  5. drop _merge
  6. 
. foreach k in 50 100 500 1000 2000{
  7. bysort kommunkod: egen Highq_`k' = mean(RatioHighq_`year'_`k')                        
>                           /*Municipality-mean */
  8. bysort kommunkod: egen Highq_`k'_pol = mean(RatioHighq_`year'_`k') if politician_`year
> '==1                                              /*Ditto for politicians*/
  9. bysort kommunkod: gen Ratio_Highq_`k'= Highq_`k'_pol/Highq_`k'
 10. }
 11. collapse Ratio_Highq_50 Ratio_Highq_100 Ratio_Highq_500 Ratio_Highq_1000 Ratio_Highq_2
> 000 
 12. gen year = `year'
 13. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_dispi
> nc_all_`year'.dta", replace
 14. }

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         6,981,805  (_merge==3)
    -----------------------------------------
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_dispinc_all_2002.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,157,824  (_merge==3)
    -----------------------------------------
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_dispinc_all_2006.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,482,465  (_merge==3)
    -----------------------------------------
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_dispinc_all_2010.dta saved

. 
. use "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_dispinc_a
> ll_2002.dta", clear

. foreach year in 2006 2010 {
  2. append using "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nho
> od_dispinc_all_`year'.dta"
  3. }

. *sum
. *scatter Ratio_Highq_50 Ratio_Highq_100 Ratio_Highq_500 Ratio_Highq_1000 Ratio_Highq_2000
>  year
. *graph export "\\micro.intra\mydocs\mydocs\dahma\my documents\OutBox\k_nearest_highq.pdf"
> , as(pdf) 
. 
. collapse Ratio_Highq_50 Ratio_Highq_100 Ratio_Highq_500 Ratio_Highq_1000 Ratio_Highq_2000
>   

. ren Ratio_Highq_50 Highq50

. ren Ratio_Highq_100 Highq100

. ren Ratio_Highq_500 Highq500

. ren Ratio_Highq_1000 Highq1000

. ren Ratio_Highq_2000 Highq2000

. gen id=1

. reshape long Highq, i(id) j(k)
(j = 50 100 500 1000 2000)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   5           
Number of variables                   6   ->   3           
j variable (5 values)                     ->   k
xij variables:
         Highq50 Highq100 ... Highq2000   ->   Highq
-----------------------------------------------------------------------------

. sum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
          id |          5           1           0          1          1
           k |          5         730    805.9156         50       2000
       Highq |          5    1.052854    .0225367   1.025639   1.079826

. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Highq_all.dta", 
> replace
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Highq_all.dta
    saved

. 
. 
. 
. 
. 
. 
. ***************************
. *Left politicians
. ***************************
. clear all

. 
. * Analys ethnic majority
. foreach year in 2002 2006 2010 {
  2. clear
  3. use "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\ethnic_maj_`ye
> ar'_temp.dta"
  4. merge 1:m XKOORD_`year' YKOORD_`year' using "\\micro.intra\Projekt\P0624$\P0624_Gem\Po
> litisk Geografi\Data\MergedData\Merged_`year'.dta"
  5. drop _merge
  6. 
. gen parti_low = lower(parti_initial)
  7. gen vald_left = 0
  8. replace vald_left = vald==1 & (parti_low =="s" | parti_low =="g" | parti_low =="v")
  9. 
. foreach k in 50 100 500 1000 2000{
 10. bysort kommunkod: egen ethnic_maj_`k' = mean(Ratioethnic_maj_`year'_`k')              
>                                           /*Municipality-mean */
 11. bysort kommunkod: egen ethnic_maj_`k'_pol = mean(Ratioethnic_maj_`year'_`k') if vald_l
> eft==1            /*Ditto for politicians*/
 12. bysort kommunkod: gen Ratio_ethnic_maj_`k'= ethnic_maj_`k'_pol/ethnic_maj_`k'
 13. }
 14. collapse Ratio_ethnic_maj_50 Ratio_ethnic_maj_100 Ratio_ethnic_maj_500 Ratio_ethnic_ma
> j_1000 Ratio_ethnic_maj_2000 
 15. gen year = `year'
 16. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_ethni
> c_maj_left_`year'.dta", replace
 17. }

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         6,981,805  (_merge==3)
    -----------------------------------------
(6,930,923 missing values generated)
(6,637 real changes made)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_ethnic_maj_left_2002.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,157,824  (_merge==3)
    -----------------------------------------
(7,106,912 missing values generated)
(6,046 real changes made)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_ethnic_maj_left_2006.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,482,465  (_merge==3)
    -----------------------------------------
(7,430,615 missing values generated)
(5,975 real changes made)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_ethnic_maj_left_2010.dta saved

. 
. use "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_ethnic_ma
> j_left_2002.dta", clear

. foreach year in 2006 2010 {
  2. append using "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nho
> od_ethnic_maj_left_`year'.dta"
  3. }

. *sum
. *scatter Ratio_ethnic_maj_50 Ratio_ethnic_maj_500 Ratio_ethnic_maj_1000 Ratio_ethnic_maj_
> 2000 year
. *graph export "\\micro.intra\mydocs\mydocs\dahma\my documents\OutBox\k_nearest_ethnic_maj
> .pdf", as(pdf) 
. 
. collapse Ratio_ethnic_maj_50 Ratio_ethnic_maj_100 Ratio_ethnic_maj_500 Ratio_ethnic_maj_1
> 000 Ratio_ethnic_maj_2000 

. ren Ratio_ethnic_maj_50 Ethnic_majority50

. ren Ratio_ethnic_maj_100 Ethnic_majority100

. ren Ratio_ethnic_maj_500 Ethnic_majority500

. ren Ratio_ethnic_maj_1000 Ethnic_majority1000

. ren Ratio_ethnic_maj_2000 Ethnic_majority2000

. gen id=1

. reshape long Ethnic_majority, i(id) j(k)
(j = 50 100 500 1000 2000)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   5           
Number of variables                   6   ->   3           
j variable (5 values)                     ->   k
xij variables:
Ethnic_majority50 Ethnic_majority100 ... Ethnic_majority2000->Ethnic_majority
-----------------------------------------------------------------------------

. sum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
          id |          5           1           0          1          1
           k |          5         730    805.9156         50       2000
Ethnic_maj~y |          5    1.001604    .0014207   .9997785   1.003061

. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Ethnic_majority_
> left.dta", replace
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\Ethnic_majority_left.dta saved

. 
. 
. 
. * Analys highed
. foreach year in 2002 2006 2010 {
  2. clear
  3. use "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\highed_`year'_
> temp.dta"
  4. merge 1:m XKOORD_`year' YKOORD_`year' using "\\micro.intra\Projekt\P0624$\P0624_Gem\Po
> litisk Geografi\Data\MergedData\Merged_`year'.dta"
  5. drop _merge
  6. 
. gen parti_low = lower(parti_initial)
  7. gen vald_left = 0
  8. replace vald_left = vald==1 & (parti_low =="s" | parti_low =="g" | parti_low =="v")
  9. 
. foreach k in 50 100 500 1000 2000{
 10. bysort kommunkod: egen Highed_`k' = mean(RatioHighed_`year'_`k')                      
>                                   /*Municipality-mean */
 11. bysort kommunkod: egen Highed_`k'_pol = mean(RatioHighed_`year'_`k') if vald_left==1  
>           /*Ditto for politicians*/
 12. bysort kommunkod: gen Ratio_Highed_`k'= Highed_`k'_pol/Highed_`k'
 13. }
 14. collapse Ratio_Highed_50 Ratio_Highed_100 Ratio_Highed_500 Ratio_Highed_1000 Ratio_Hig
> hed_2000 
 15. gen year = `year'
 16. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_educa
> tion_left_`year'.dta", replace
 17. }

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         6,981,805  (_merge==3)
    -----------------------------------------
(6,930,923 missing values generated)
(6,637 real changes made)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_education_left_2002.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,157,824  (_merge==3)
    -----------------------------------------
(7,106,912 missing values generated)
(6,046 real changes made)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_education_left_2006.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,482,465  (_merge==3)
    -----------------------------------------
(7,430,615 missing values generated)
(5,975 real changes made)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_education_left_2010.dta saved

. 
. use "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_education
> _left_2002.dta", clear

. foreach year in 2006 2010 {
  2. append using "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nho
> od_education_left_`year'.dta"
  3. }

. 
. *sum
. *scatter Ratio_Highed_50 Ratio_Highed_500 Ratio_Highed_1000 Ratio_Highed_2000 year
. *graph export "\\micro.intra\mydocs\mydocs\dahma\my documents\OutBox\k_nearest_highed.pdf
> ", as(pdf) 
. collapse Ratio_Highed_50 Ratio_Highed_100 Ratio_Highed_500 Ratio_Highed_1000 Ratio_Highed
> _2000 

. ren Ratio_Highed_50 Highed50

. ren Ratio_Highed_100 Highed100

. ren Ratio_Highed_500 Highed500

. ren Ratio_Highed_1000 Highed1000

. ren Ratio_Highed_2000 Highed2000

. gen id=1

. reshape long Highed, i(id) j(k)
(j = 50 100 500 1000 2000)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   5           
Number of variables                   6   ->   3           
j variable (5 values)                     ->   k
xij variables:
      Highed50 Highed100 ... Highed2000   ->   Highed
-----------------------------------------------------------------------------

. sum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
          id |          5           1           0          1          1
           k |          5         730    805.9156         50       2000
      Highed |          5    1.009398    .0105844   .9982667   1.023127

. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Highed_left.dta"
> , replace
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Highed_left.dta
    saved

. 
. 
. 
. 
. * Analys highq
. foreach year in 2002 2006 2010 {
  2. clear
  3. use "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\highq_`year'_t
> emp.dta"
  4. merge 1:m XKOORD_`year' YKOORD_`year' using "\\micro.intra\Projekt\P0624$\P0624_Gem\Po
> litisk Geografi\Data\MergedData\Merged_`year'.dta"
  5. drop _merge
  6. 
. gen parti_low = lower(parti_initial)
  7. gen vald_left = 0
  8. replace vald_left = vald==1 & (parti_low =="s" | parti_low =="g" | parti_low =="v")
  9. 
. foreach k in 50 100 500 1000 2000{
 10. bysort kommunkod: egen Highq_`k' = mean(RatioHighq_`year'_`k')                        
>                           /*Municipality-mean */
 11. bysort kommunkod: egen Highq_`k'_pol = mean(RatioHighq_`year'_`k') if vald_left==1    
>           /*Ditto for politicians*/
 12. bysort kommunkod: gen Ratio_Highq_`k'= Highq_`k'_pol/Highq_`k'
 13. }
 14. collapse Ratio_Highq_50 Ratio_Highq_100 Ratio_Highq_500 Ratio_Highq_1000 Ratio_Highq_2
> 000 
 15. gen year = `year'
 16. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_dispi
> nc_left_`year'.dta", replace
 17. }

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         6,981,805  (_merge==3)
    -----------------------------------------
(6,930,923 missing values generated)
(6,637 real changes made)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_dispinc_left_2002.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,157,824  (_merge==3)
    -----------------------------------------
(7,106,912 missing values generated)
(6,046 real changes made)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_dispinc_left_2006.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,482,465  (_merge==3)
    -----------------------------------------
(7,430,615 missing values generated)
(5,975 real changes made)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_dispinc_left_2010.dta saved

. 
. use "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_dispinc_l
> eft_2002.dta", clear

. foreach year in 2006 2010 {
  2. append using "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nho
> od_dispinc_left_`year'.dta"
  3. }

. *sum
. *scatter Ratio_Highq_50 Ratio_Highq_100 Ratio_Highq_500 Ratio_Highq_1000 Ratio_Highq_2000
>  year
. *graph export "\\micro.intra\mydocs\mydocs\dahma\my documents\OutBox\k_nearest_highq.pdf"
> , as(pdf) 
. 
. collapse Ratio_Highq_50 Ratio_Highq_100 Ratio_Highq_500 Ratio_Highq_1000 Ratio_Highq_2000
>   

. ren Ratio_Highq_50 Highq50

. ren Ratio_Highq_100 Highq100

. ren Ratio_Highq_500 Highq500

. ren Ratio_Highq_1000 Highq1000

. ren Ratio_Highq_2000 Highq2000

. gen id=1

. reshape long Highq, i(id) j(k)
(j = 50 100 500 1000 2000)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   5           
Number of variables                   6   ->   3           
j variable (5 values)                     ->   k
xij variables:
         Highq50 Highq100 ... Highq2000   ->   Highq
-----------------------------------------------------------------------------

. sum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
          id |          5           1           0          1          1
           k |          5         730    805.9156         50       2000
       Highq |          5    1.025156    .0193888   1.003239   1.048429

. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Highq_left.dta",
>  replace
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Highq_left.dta
    saved

. 
. 
. 
. 
.   
. ***************************
. *Right politicians
. ***************************
. clear all

. 
. * Analys ethnic majority
. foreach year in 2002 2006 2010 {
  2. clear
  3. use "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\ethnic_maj_`ye
> ar'_temp.dta"
  4. merge 1:m XKOORD_`year' YKOORD_`year' using "\\micro.intra\Projekt\P0624$\P0624_Gem\Po
> litisk Geografi\Data\MergedData\Merged_`year'.dta"
  5. drop _merge
  6. 
. gen parti_low = lower(parti_initial)
  7. gen vald_right = 0
  8. replace vald_right = vald==1 & (parti_low =="c" | parti_low =="m" | parti_low =="k" | 
> parti_low =="f")
  9. 
. foreach k in 50 100 500 1000 2000{
 10. bysort kommunkod: egen ethnic_maj_`k' = mean(Ratioethnic_maj_`year'_`k')              
>                                           /*Municipality-mean */
 11. bysort kommunkod: egen ethnic_maj_`k'_pol = mean(Ratioethnic_maj_`year'_`k') if vald_r
> ight==1           /*Ditto for politicians*/
 12. bysort kommunkod: gen Ratio_ethnic_maj_`k'= ethnic_maj_`k'_pol/ethnic_maj_`k'
 13. }
 14. collapse Ratio_ethnic_maj_50 Ratio_ethnic_maj_100 Ratio_ethnic_maj_500 Ratio_ethnic_ma
> j_1000 Ratio_ethnic_maj_2000 
 15. gen year = `year'
 16. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_ethni
> c_maj_right_`year'.dta", replace
 17. }

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         6,981,805  (_merge==3)
    -----------------------------------------
(6,930,923 missing values generated)
(6,016 real changes made)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_ethnic_maj_right_2002.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,157,824  (_merge==3)
    -----------------------------------------
(7,106,912 missing values generated)
(6,148 real changes made)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_ethnic_maj_right_2006.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,482,465  (_merge==3)
    -----------------------------------------
(7,430,615 missing values generated)
(5,870 real changes made)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_ethnic_maj_right_2010.dta saved

. 
. use "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_ethnic_ma
> j_right_2002.dta", clear

. foreach year in 2006 2010 {
  2. append using "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nho
> od_ethnic_maj_right_`year'.dta"
  3. }

. *sum
. *scatter Ratio_ethnic_maj_50 Ratio_ethnic_maj_500 Ratio_ethnic_maj_1000 Ratio_ethnic_maj_
> 2000 year
. *graph export "\\micro.intra\mydocs\mydocs\dahma\my documents\OutBox\k_nearest_ethnic_maj
> .pdf", as(pdf) 
. 
. collapse Ratio_ethnic_maj_50 Ratio_ethnic_maj_100 Ratio_ethnic_maj_500 Ratio_ethnic_maj_1
> 000 Ratio_ethnic_maj_2000 

. ren Ratio_ethnic_maj_50 Ethnic_majority50

. ren Ratio_ethnic_maj_100 Ethnic_majority100

. ren Ratio_ethnic_maj_500 Ethnic_majority500

. ren Ratio_ethnic_maj_1000 Ethnic_majority1000

. ren Ratio_ethnic_maj_2000 Ethnic_majority2000

. gen id=1

. reshape long Ethnic_majority, i(id) j(k)
(j = 50 100 500 1000 2000)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   5           
Number of variables                   6   ->   3           
j variable (5 values)                     ->   k
xij variables:
Ethnic_majority50 Ethnic_majority100 ... Ethnic_majority2000->Ethnic_majority
-----------------------------------------------------------------------------

. sum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
          id |          5           1           0          1          1
           k |          5         730    805.9156         50       2000
Ethnic_maj~y |          5    1.015712    .0023657   1.012157   1.017776

. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Ethnic_majority_
> right.dta", replace
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\Ethnic_majority_right.dta saved

. 
. 
. 
. * Analys highed
. foreach year in 2002 2006 2010 {
  2. clear
  3. use "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\highed_`year'_
> temp.dta"
  4. merge 1:m XKOORD_`year' YKOORD_`year' using "\\micro.intra\Projekt\P0624$\P0624_Gem\Po
> litisk Geografi\Data\MergedData\Merged_`year'.dta"
  5. drop _merge
  6. 
. gen parti_low = lower(parti_initial)
  7. gen vald_right = 0
  8. replace vald_right = vald==1 & (parti_low =="c" | parti_low =="m" | parti_low =="k" | 
> parti_low =="f")
  9. 
. foreach k in 50 100 500 1000 2000{
 10. bysort kommunkod: egen Highed_`k' = mean(RatioHighed_`year'_`k')                      
>                                   /*Municipality-mean */
 11. bysort kommunkod: egen Highed_`k'_pol = mean(RatioHighed_`year'_`k') if vald_right==1 
>           /*Ditto for politicians*/
 12. bysort kommunkod: gen Ratio_Highed_`k'= Highed_`k'_pol/Highed_`k'
 13. }
 14. collapse Ratio_Highed_50 Ratio_Highed_100 Ratio_Highed_500 Ratio_Highed_1000 Ratio_Hig
> hed_2000 
 15. gen year = `year'
 16. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_educa
> tion_right_`year'.dta", replace
 17. }

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         6,981,805  (_merge==3)
    -----------------------------------------
(6,930,923 missing values generated)
(6,016 real changes made)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_education_right_2002.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,157,824  (_merge==3)
    -----------------------------------------
(7,106,912 missing values generated)
(6,148 real changes made)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_education_right_2006.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,482,465  (_merge==3)
    -----------------------------------------
(7,430,615 missing values generated)
(5,870 real changes made)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_education_right_2010.dta saved

. 
. use "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_education
> _right_2002.dta", clear

. foreach year in 2006 2010 {
  2. append using "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nho
> od_education_right_`year'.dta"
  3. }

. 
. *sum
. *scatter Ratio_Highed_50 Ratio_Highed_500 Ratio_Highed_1000 Ratio_Highed_2000 year
. *graph export "\\micro.intra\mydocs\mydocs\dahma\my documents\OutBox\k_nearest_highed.pdf
> ", as(pdf) 
. collapse Ratio_Highed_50 Ratio_Highed_100 Ratio_Highed_500 Ratio_Highed_1000 Ratio_Highed
> _2000 

. ren Ratio_Highed_50 Highed50

. ren Ratio_Highed_100 Highed100

. ren Ratio_Highed_500 Highed500

. ren Ratio_Highed_1000 Highed1000

. ren Ratio_Highed_2000 Highed2000

. gen id=1

. reshape long Highed, i(id) j(k)
(j = 50 100 500 1000 2000)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   5           
Number of variables                   6   ->   3           
j variable (5 values)                     ->   k
xij variables:
      Highed50 Highed100 ... Highed2000   ->   Highed
-----------------------------------------------------------------------------

. sum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
          id |          5           1           0          1          1
           k |          5         730    805.9156         50       2000
      Highed |          5    1.056135    .0272257   1.024917   1.091004

. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Highed_right.dta
> ", replace
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Highed_right.dta
    saved

. 
. 
. 
. 
. * Analys highq
. foreach year in 2002 2006 2010 {
  2. clear
  3. use "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\highq_`year'_t
> emp.dta"
  4. merge 1:m XKOORD_`year' YKOORD_`year' using "\\micro.intra\Projekt\P0624$\P0624_Gem\Po
> litisk Geografi\Data\MergedData\Merged_`year'.dta"
  5. drop _merge
  6. 
. gen parti_low = lower(parti_initial)
  7. gen vald_right = 0
  8. replace vald_right = vald==1 & (parti_low =="c" | parti_low =="m" | parti_low =="k" | 
> parti_low =="f")
  9. 
. foreach k in 50 100 500 1000 2000{
 10. bysort kommunkod: egen Highq_`k' = mean(RatioHighq_`year'_`k')                        
>                           /*Municipality-mean*/
 11. bysort kommunkod: egen Highq_`k'_pol = mean(RatioHighq_`year'_`k') if vald_right==1   
>           /*Ditto for politicians*/
 12. bysort kommunkod: gen Ratio_Highq_`k'= Highq_`k'_pol/Highq_`k'
 13. }
 14. collapse Ratio_Highq_50 Ratio_Highq_100 Ratio_Highq_500 Ratio_Highq_1000 Ratio_Highq_2
> 000 
 15. gen year = `year'
 16. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_dispi
> nc_right_`year'.dta", replace
 17. }

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         6,981,805  (_merge==3)
    -----------------------------------------
(6,930,923 missing values generated)
(6,016 real changes made)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_dispinc_right_2002.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,157,824  (_merge==3)
    -----------------------------------------
(7,106,912 missing values generated)
(6,148 real changes made)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_dispinc_right_2006.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,482,465  (_merge==3)
    -----------------------------------------
(7,430,615 missing values generated)
(5,870 real changes made)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_dispinc_right_2010.dta saved

. 
. use "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_dispinc_r
> ight_2002.dta", clear

. foreach year in 2006 2010 {
  2. append using "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nho
> od_dispinc_right_`year'.dta"
  3. }

. *sum
. *scatter Ratio_Highq_50 Ratio_Highq_100 Ratio_Highq_500 Ratio_Highq_1000 Ratio_Highq_2000
>  year
. *graph export "\\micro.intra\mydocs\mydocs\dahma\my documents\OutBox\k_nearest_highq.pdf"
> , as(pdf) 
. 
. collapse Ratio_Highq_50 Ratio_Highq_100 Ratio_Highq_500 Ratio_Highq_1000 Ratio_Highq_2000
>   

. ren Ratio_Highq_50 Highq50

. ren Ratio_Highq_100 Highq100

. ren Ratio_Highq_500 Highq500

. ren Ratio_Highq_1000 Highq1000

. ren Ratio_Highq_2000 Highq2000

. gen id=1

. reshape long Highq, i(id) j(k)
(j = 50 100 500 1000 2000)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   5           
Number of variables                   6   ->   3           
j variable (5 values)                     ->   k
xij variables:
         Highq50 Highq100 ... Highq2000   ->   Highq
-----------------------------------------------------------------------------

. sum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
          id |          5           1           0          1          1
           k |          5         730    805.9156         50       2000
       Highq |          5    1.087078    .0278184   1.051761   1.120001

. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Highq_right.dta"
> , replace
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Highq_right.dta
    saved

. 
. 
. 
. 
. 
. clear all

. 
. **********************************
. * All politicians: DISADVANTAGE **
. **********************************
. 
. * Analys ethnic minority
. foreach year in 2002 2006 2010 {
  2. clear
  3. use "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\ethnic_maj_`ye
> ar'_temp.dta"
  4. merge 1:m XKOORD_`year' YKOORD_`year' using "\\micro.intra\Projekt\P0624$\P0624_Gem\Po
> litisk Geografi\Data\MergedData\Merged_`year'.dta"
  5. drop _merge
  6. 
. foreach k in 50 100 500 1000 2000{
  7. gen Ratioethnic_min_`year'_`k' = 1-Ratioethnic_maj_`year'_`k'
  8. bysort kommunkod: egen ethnic_min_`k' = mean(Ratioethnic_min_`year'_`k')              
>                                           /*Municipality-mean*/
  9. bysort kommunkod: egen ethnic_min_`k'_pol = mean(Ratioethnic_min_`year'_`k') if politi
> cian_`year'==1            /*Ditto for politicians*/
 10. bysort kommunkod: gen Ratio_ethnic_min_`k'= ethnic_min_`k'_pol/ethnic_min_`k'
 11. }
 12. collapse Ratio_ethnic_min_50 Ratio_ethnic_min_100 Ratio_ethnic_min_500 Ratio_ethnic_mi
> n_1000 Ratio_ethnic_min_2000 
 13. gen year = `year'
 14. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_ethni
> c_min_`year'.dta", replace
 15. }

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         6,981,805  (_merge==3)
    -----------------------------------------
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_ethnic_min_2002.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,157,824  (_merge==3)
    -----------------------------------------
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_ethnic_min_2006.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,482,465  (_merge==3)
    -----------------------------------------
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_ethnic_min_2010.dta saved

. 
. use "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_ethnic_mi
> n_2002.dta", clear

. foreach year in 2006 2010 {
  2. append using "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nho
> od_ethnic_min_`year'.dta"
  3. }

. *sum
. *scatter Ratio_ethnic_maj_50 Ratio_ethnic_maj_500 Ratio_ethnic_maj_1000 Ratio_ethnic_min_
> 2000 year
. *graph export "\\micro.intra\mydocs\mydocs\dahma\my documents\OutBox\k_nearest_ethnic_min
> .pdf", as(pdf) 
. 
. collapse Ratio_ethnic_min_50 Ratio_ethnic_min_100 Ratio_ethnic_min_500 Ratio_ethnic_min_1
> 000 Ratio_ethnic_min_2000 

. ren Ratio_ethnic_min_50 Ethnic_minority50

. ren Ratio_ethnic_min_100 Ethnic_minority100

. ren Ratio_ethnic_min_500 Ethnic_minority500

. ren Ratio_ethnic_min_1000 Ethnic_minority1000

. ren Ratio_ethnic_min_2000 Ethnic_minority2000

. gen id=1

. reshape long Ethnic_minority, i(id) j(k)
(j = 50 100 500 1000 2000)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   5           
Number of variables                   6   ->   3           
j variable (5 values)                     ->   k
xij variables:
Ethnic_minority50 Ethnic_minority100 ... Ethnic_minority2000->Ethnic_minority
-----------------------------------------------------------------------------

. sum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
          id |          5           1           0          1          1
           k |          5         730    805.9156         50       2000
Ethnic_min~y |          5    .8692383    .0405516   .8275547   .9212295

. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Ethnic_minority.
> dta", replace
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\Ethnic_minority.dta saved

. 
. 
. 
. 
. * Analys highed
. foreach year in 2002 2006 2010 {
  2. clear
  3. use "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\highed_`year'_
> temp.dta"
  4. merge 1:m XKOORD_`year' YKOORD_`year' using "\\micro.intra\Projekt\P0624$\P0624_Gem\Po
> litisk Geografi\Data\MergedData\Merged_`year'.dta"
  5. drop _merge
  6. 
. foreach k in 50 100 500 1000 2000{
  7. gen RatioLowed_`year'_`k' = 1-RatioHighed_`year'_`k'
  8. bysort kommunkod: egen Lowed_`k' = mean(RatioLowed_`year'_`k')                        
>                           /*Municipality-mean */
  9. bysort kommunkod: egen Lowed_`k'_pol = mean(RatioLowed_`year'_`k') if politician_`year
> '==1              /*Ditto for politicians*/
 10. bysort kommunkod: gen Ratio_Lowed_`k'= Lowed_`k'_pol/Lowed_`k'
 11. }
 12. collapse Ratio_Lowed_50 Ratio_Lowed_100 Ratio_Lowed_500 Ratio_Lowed_1000 Ratio_Lowed_2
> 000 
 13. gen year = `year'
 14. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_lowed
> ucation_`year'.dta", replace
 15. }

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         6,981,805  (_merge==3)
    -----------------------------------------
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_loweducation_2002.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,157,824  (_merge==3)
    -----------------------------------------
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_loweducation_2006.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,482,465  (_merge==3)
    -----------------------------------------
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_loweducation_2010.dta saved

. 
. use "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_loweducat
> ion_2002.dta", clear

. foreach year in 2006 2010 {
  2. append using "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nho
> od_loweducation_`year'.dta"
  3. }

. 
. *sum
. *scatter Ratio_Highed_50 Ratio_Highed_500 Ratio_Highed_1000 Ratio_Lowed_2000 year
. *graph export "\\micro.intra\mydocs\mydocs\dahma\my documents\OutBox\k_nearest_Lowed.pdf"
> , as(pdf) 
. collapse Ratio_Lowed_50 Ratio_Lowed_100 Ratio_Lowed_500 Ratio_Lowed_1000 Ratio_Lowed_2000
>  

. ren Ratio_Lowed_50 Lowed50

. ren Ratio_Lowed_100 Lowed100

. ren Ratio_Lowed_500 Lowed500

. ren Ratio_Lowed_1000 Lowed1000

. ren Ratio_Lowed_2000 Lowed2000

. gen id=1

. reshape long Lowed, i(id) j(k)
(j = 50 100 500 1000 2000)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   5           
Number of variables                   6   ->   3           
j variable (5 values)                     ->   k
xij variables:
         Lowed50 Lowed100 ... Lowed2000   ->   Lowed
-----------------------------------------------------------------------------

. sum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
          id |          5           1           0          1          1
           k |          5         730    805.9156         50       2000
       Lowed |          5    .9883597    .0053629   .9816673   .9945825

. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Lowed.dta", repl
> ace
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Lowed.dta saved

. 
. 
. 
. 
. * Analys highq
. foreach year in 2002 2006 2010 {
  2. clear
  3. use "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\highq_`year'_t
> emp.dta"
  4. merge 1:m XKOORD_`year' YKOORD_`year' using "\\micro.intra\Projekt\P0624$\P0624_Gem\Po
> litisk Geografi\Data\MergedData\Merged_`year'.dta"
  5. drop _merge
  6. 
. foreach k in 50 100 500 1000 2000{
  7. gen RatioLowq_`year'_`k' = 1-RatioHighq_`year'_`k'
  8. bysort kommunkod: egen Lowq_`k' = mean(RatioLowq_`year'_`k')                          
>                           /*Municipality-mean */
  9. bysort kommunkod: egen Lowq_`k'_pol = mean(RatioLowq_`year'_`k') if politician_`year'=
> =1                /*Ditto for politicians*/
 10. bysort kommunkod: gen Ratio_Lowq_`k'= Lowq_`k'_pol/Lowq_`k'
 11. }
 12. collapse Ratio_Lowq_50 Ratio_Lowq_100 Ratio_Lowq_500 Ratio_Lowq_1000 Ratio_Lowq_2000 
 13. gen year = `year'
 14. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_Lowq_
> `year'.dta", replace
 15. }

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         6,981,805  (_merge==3)
    -----------------------------------------
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
(6,968,545 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_Lowq_2002.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,157,824  (_merge==3)
    -----------------------------------------
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
(7,144,760 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_Lowq_2006.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,482,465  (_merge==3)
    -----------------------------------------
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
(7,469,505 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_Lowq_2010.dta saved

. 
. use "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_Lowq_2002
> .dta", clear

. foreach year in 2006 2010 {
  2. append using "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nho
> od_Lowq_`year'.dta"
  3. }

. *sum
. *scatter Ratio_Highq_50 Ratio_Highq_100 Ratio_Highq_500 Ratio_Highq_1000 Ratio_Lowq_2000 
> year
. *graph export "\\micro.intra\mydocs\mydocs\dahma\my documents\OutBox\k_nearest_Lowq.pdf",
>  as(pdf) 
. 
. collapse Ratio_Lowq_50 Ratio_Lowq_100 Ratio_Lowq_500 Ratio_Lowq_1000 Ratio_Lowq_2000  

. ren Ratio_Lowq_50 Lowq50

. ren Ratio_Lowq_100 Lowq100

. ren Ratio_Lowq_500 Lowq500

. ren Ratio_Lowq_1000 Lowq1000

. ren Ratio_Lowq_2000 Lowq2000

. gen id=1

. reshape long Lowq, i(id) j(k)
(j = 50 100 500 1000 2000)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   5           
Number of variables                   6   ->   3           
j variable (5 values)                     ->   k
xij variables:
            Lowq50 Lowq100 ... Lowq2000   ->   Lowq
-----------------------------------------------------------------------------

. sum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
          id |          5           1           0          1          1
           k |          5         730    805.9156         50       2000
        Lowq |          5    .9843215    .0062204   .9770275   .9919159

. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Lowq.dta", repla
> ce
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Lowq.dta saved

. 
. 
. 
. 
. 
. ******************
. * Left politicians
. ******************
. 
. clear all

. 
. * Analys ethnic minority
. foreach year in 2002 2006 2010 {
  2. clear
  3. use "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\ethnic_maj_`ye
> ar'_temp.dta"
  4. merge 1:m XKOORD_`year' YKOORD_`year' using "\\micro.intra\Projekt\P0624$\P0624_Gem\Po
> litisk Geografi\Data\MergedData\Merged_`year'.dta"
  5. drop _merge
  6. 
. gen parti_low = lower(parti_initial)
  7. gen vald_left = 0
  8. replace vald_left = vald==1 & (parti_low =="s" | parti_low =="g" | parti_low =="v")
  9. 
. foreach k in 50 100 500 1000 2000{
 10. gen Ratioethnic_min_`year'_`k' = 1-Ratioethnic_maj_`year'_`k'
 11. bysort kommunkod: egen ethnic_min_`k' = mean(Ratioethnic_min_`year'_`k')              
>                                           /*Municipality-mean */
 12. bysort kommunkod: egen ethnic_min_`k'_pol = mean(Ratioethnic_min_`year'_`k') if vald_l
> eft==1            /*Ditto for politicians*/
 13. bysort kommunkod: gen Ratio_ethnic_min_`k'= ethnic_min_`k'_pol/ethnic_min_`k'
 14. }
 15. collapse Ratio_ethnic_min_50 Ratio_ethnic_min_100 Ratio_ethnic_min_500 Ratio_ethnic_mi
> n_1000 Ratio_ethnic_min_2000 
 16. gen year = `year'
 17. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_ethni
> c_min_left_`year'.dta", replace
 18. }

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         6,981,805  (_merge==3)
    -----------------------------------------
(6,930,923 missing values generated)
(6,637 real changes made)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_ethnic_min_left_2002.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,157,824  (_merge==3)
    -----------------------------------------
(7,106,912 missing values generated)
(6,046 real changes made)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_ethnic_min_left_2006.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,482,465  (_merge==3)
    -----------------------------------------
(7,430,615 missing values generated)
(5,975 real changes made)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_ethnic_min_left_2010.dta saved

. 
. use "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_ethnic_mi
> n_left_2002.dta", clear

. foreach year in 2006 2010 {
  2. append using "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nho
> od_ethnic_min_left_`year'.dta"
  3. }

. *sum
. *scatter Ratio_ethnic_maj_50 Ratio_ethnic_maj_500 Ratio_ethnic_maj_1000 Ratio_ethnic_min_
> 2000 year
. *graph export "\\micro.intra\mydocs\mydocs\dahma\my documents\OutBox\k_nearest_ethnic_min
> .pdf", as(pdf) 
. 
. collapse Ratio_ethnic_min_50 Ratio_ethnic_min_100 Ratio_ethnic_min_500 Ratio_ethnic_min_1
> 000 Ratio_ethnic_min_2000 

. ren Ratio_ethnic_min_50 Ethnic_minority50

. ren Ratio_ethnic_min_100 Ethnic_minority100

. ren Ratio_ethnic_min_500 Ethnic_minority500

. ren Ratio_ethnic_min_1000 Ethnic_minority1000

. ren Ratio_ethnic_min_2000 Ethnic_minority2000

. gen id=1

. reshape long Ethnic_minority, i(id) j(k)
(j = 50 100 500 1000 2000)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   5           
Number of variables                   6   ->   3           
j variable (5 values)                     ->   k
xij variables:
Ethnic_minority50 Ethnic_minority100 ... Ethnic_minority2000->Ethnic_minority
-----------------------------------------------------------------------------

. sum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
          id |          5           1           0          1          1
           k |          5         730    805.9156         50       2000
Ethnic_min~y |          5    .9613362    .0286007   .9319101   .9935147

. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Ethnic_minority_
> left.dta", replace
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\Ethnic_minority_left.dta saved

. 
. 
. 
. 
. * Analys highed
. foreach year in 2002 2006 2010 {
  2. clear
  3. use "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\highed_`year'_
> temp.dta"
  4. merge 1:m XKOORD_`year' YKOORD_`year' using "\\micro.intra\Projekt\P0624$\P0624_Gem\Po
> litisk Geografi\Data\MergedData\Merged_`year'.dta"
  5. drop _merge
  6. 
. gen parti_low = lower(parti_initial)
  7. gen vald_left = 0
  8. replace vald_left = vald==1 & (parti_low =="s" | parti_low =="g" | parti_low =="v")
  9. 
. foreach k in 50 100 500 1000 2000{
 10. gen RatioLowed_`year'_`k' = 1-RatioHighed_`year'_`k'
 11. bysort kommunkod: egen Lowed_`k' = mean(RatioLowed_`year'_`k')                        
>                           /*Municipality-mean */
 12. bysort kommunkod: egen Lowed_`k'_pol = mean(RatioLowed_`year'_`k') if vald_left==1    
>           /*Ditto for politicians*/
 13. bysort kommunkod: gen Ratio_Lowed_`k'= Lowed_`k'_pol/Lowed_`k'
 14. }
 15. collapse Ratio_Lowed_50 Ratio_Lowed_100 Ratio_Lowed_500 Ratio_Lowed_1000 Ratio_Lowed_2
> 000 
 16. gen year = `year'
 17. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_lowed
> ucation_left_`year'.dta", replace
 18. }

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         6,981,805  (_merge==3)
    -----------------------------------------
(6,930,923 missing values generated)
(6,637 real changes made)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_loweducation_left_2002.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,157,824  (_merge==3)
    -----------------------------------------
(7,106,912 missing values generated)
(6,046 real changes made)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_loweducation_left_2006.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,482,465  (_merge==3)
    -----------------------------------------
(7,430,615 missing values generated)
(5,975 real changes made)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_loweducation_left_2010.dta saved

. 
. use "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_loweducat
> ion_left_2002.dta", clear

. foreach year in 2006 2010 {
  2. append using "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nho
> od_loweducation_left_`year'.dta"
  3. }

. 
. *sum
. *scatter Ratio_Highed_50 Ratio_Highed_500 Ratio_Highed_1000 Ratio_Lowed_2000 year
. *graph export "\\micro.intra\mydocs\mydocs\dahma\my documents\OutBox\k_nearest_Lowed.pdf"
> , as(pdf) 
. collapse Ratio_Lowed_50 Ratio_Lowed_100 Ratio_Lowed_500 Ratio_Lowed_1000 Ratio_Lowed_2000
>  

. ren Ratio_Lowed_50 Lowed50

. ren Ratio_Lowed_100 Lowed100

. ren Ratio_Lowed_500 Lowed500

. ren Ratio_Lowed_1000 Lowed1000

. ren Ratio_Lowed_2000 Lowed2000

. gen id=1

. reshape long Lowed, i(id) j(k)
(j = 50 100 500 1000 2000)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   5           
Number of variables                   6   ->   3           
j variable (5 values)                     ->   k
xij variables:
         Lowed50 Lowed100 ... Lowed2000   ->   Lowed
-----------------------------------------------------------------------------

. sum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
          id |          5           1           0          1          1
           k |          5         730    805.9156         50       2000
       Lowed |          5    .9963231    .0027908   .9927148   .9993497

. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Lowed_left.dta",
>  replace
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Lowed_left.dta
    saved

. 
. 
. 
. 
. * Analys highq
. foreach year in 2002 2006 2010 {
  2. clear
  3. use "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\highq_`year'_t
> emp.dta"
  4. merge 1:m XKOORD_`year' YKOORD_`year' using "\\micro.intra\Projekt\P0624$\P0624_Gem\Po
> litisk Geografi\Data\MergedData\Merged_`year'.dta"
  5. drop _merge
  6. 
. gen parti_low = lower(parti_initial)
  7. gen vald_left = 0
  8. replace vald_left = vald==1 & (parti_low =="s" | parti_low =="g" | parti_low =="v")
  9. 
. foreach k in 50 100 500 1000 2000{
 10. gen RatioLowq_`year'_`k' = 1-RatioHighq_`year'_`k'
 11. bysort kommunkod: egen Lowq_`k' = mean(RatioLowq_`year'_`k')                          
>                           /*Municipality-mean */
 12. bysort kommunkod: egen Lowq_`k'_pol = mean(RatioLowq_`year'_`k') if vald_left==1      
>           /*Ditto for politicians*/
 13. bysort kommunkod: gen Ratio_Lowq_`k'= Lowq_`k'_pol/Lowq_`k'
 14. }
 15. collapse Ratio_Lowq_50 Ratio_Lowq_100 Ratio_Lowq_500 Ratio_Lowq_1000 Ratio_Lowq_2000 
 16. gen year = `year'
 17. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_Lowq_
> left_`year'.dta", replace
 18. }

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         6,981,805  (_merge==3)
    -----------------------------------------
(6,930,923 missing values generated)
(6,637 real changes made)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
(6,975,168 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_Lowq_left_2002.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,157,824  (_merge==3)
    -----------------------------------------
(7,106,912 missing values generated)
(6,046 real changes made)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
(7,151,778 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_Lowq_left_2006.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,482,465  (_merge==3)
    -----------------------------------------
(7,430,615 missing values generated)
(5,975 real changes made)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
(7,476,490 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_Lowq_left_2010.dta saved

. 
. use "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_Lowq_left
> _2002.dta", clear

. foreach year in 2006 2010 {
  2. append using "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nho
> od_Lowq_left_`year'.dta"
  3. }

. *sum
. *scatter Ratio_Highq_50 Ratio_Highq_100 Ratio_Highq_500 Ratio_Highq_1000 Ratio_Lowq_2000 
> year
. *graph export "\\micro.intra\mydocs\mydocs\dahma\my documents\OutBox\k_nearest_Lowq.pdf",
>  as(pdf) 
. 
. collapse Ratio_Lowq_50 Ratio_Lowq_100 Ratio_Lowq_500 Ratio_Lowq_1000 Ratio_Lowq_2000  

. ren Ratio_Lowq_50 Lowq50

. ren Ratio_Lowq_100 Lowq100

. ren Ratio_Lowq_500 Lowq500

. ren Ratio_Lowq_1000 Lowq1000

. ren Ratio_Lowq_2000 Lowq2000

. gen id=1

. reshape long Lowq, i(id) j(k)
(j = 50 100 500 1000 2000)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   5           
Number of variables                   6   ->   3           
j variable (5 values)                     ->   k
xij variables:
            Lowq50 Lowq100 ... Lowq2000   ->   Lowq
-----------------------------------------------------------------------------

. sum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
          id |          5           1           0          1          1
           k |          5         730    805.9156         50       2000
        Lowq |          5    .9938882    .0047823   .9881975   .9993718

. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Lowq_left.dta", 
> replace
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Lowq_left.dta
    saved

. 
. 
. 
. 
. 
. 
. 
. ******************
. * Right politicians
. ******************
. 
. clear all

. 
. * Analys ethnic minority
. foreach year in 2002 2006 2010 {
  2. clear
  3. use "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\ethnic_maj_`ye
> ar'_temp.dta"
  4. merge 1:m XKOORD_`year' YKOORD_`year' using "\\micro.intra\Projekt\P0624$\P0624_Gem\Po
> litisk Geografi\Data\MergedData\Merged_`year'.dta"
  5. drop _merge
  6. 
. gen parti_low = lower(parti_initial)
  7. gen vald_right = 0
  8. replace vald_right = vald==1 & (parti_low =="c" | parti_low =="m" | parti_low =="k" | 
> parti_low =="f")
  9. 
. foreach k in 50 100 500 1000 2000{
 10. gen Ratioethnic_min_`year'_`k' = 1-Ratioethnic_maj_`year'_`k'
 11. bysort kommunkod: egen ethnic_min_`k' = mean(Ratioethnic_min_`year'_`k')              
>                                           /*Municipality-mean */
 12. bysort kommunkod: egen ethnic_min_`k'_pol = mean(Ratioethnic_min_`year'_`k') if vald_r
> ight==1           /*Ditto for politicians*/
 13. bysort kommunkod: gen Ratio_ethnic_min_`k'= ethnic_min_`k'_pol/ethnic_min_`k'
 14. }
 15. collapse Ratio_ethnic_min_50 Ratio_ethnic_min_100 Ratio_ethnic_min_500 Ratio_ethnic_mi
> n_1000 Ratio_ethnic_min_2000 
 16. gen year = `year'
 17. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_ethni
> c_min_right_`year'.dta", replace
 18. }

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         6,981,805  (_merge==3)
    -----------------------------------------
(6,930,923 missing values generated)
(6,016 real changes made)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_ethnic_min_right_2002.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,157,824  (_merge==3)
    -----------------------------------------
(7,106,912 missing values generated)
(6,148 real changes made)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_ethnic_min_right_2006.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,482,465  (_merge==3)
    -----------------------------------------
(7,430,615 missing values generated)
(5,870 real changes made)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_ethnic_min_right_2010.dta saved

. 
. use "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_ethnic_mi
> n_right_2002.dta", clear

. foreach year in 2006 2010 {
  2. append using "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nho
> od_ethnic_min_right_`year'.dta"
  3. }

. *sum
. *scatter Ratio_ethnic_maj_50 Ratio_ethnic_maj_500 Ratio_ethnic_maj_1000 Ratio_ethnic_min_
> 2000 year
. *graph export "\\micro.intra\mydocs\mydocs\dahma\my documents\OutBox\k_nearest_ethnic_min
> .pdf", as(pdf) 
. 
. collapse Ratio_ethnic_min_50 Ratio_ethnic_min_100 Ratio_ethnic_min_500 Ratio_ethnic_min_1
> 000 Ratio_ethnic_min_2000 

. ren Ratio_ethnic_min_50 Ethnic_minority50

. ren Ratio_ethnic_min_100 Ethnic_minority100

. ren Ratio_ethnic_min_500 Ethnic_minority500

. ren Ratio_ethnic_min_1000 Ethnic_minority1000

. ren Ratio_ethnic_min_2000 Ethnic_minority2000

. gen id=1

. reshape long Ethnic_minority, i(id) j(k)
(j = 50 100 500 1000 2000)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   5           
Number of variables                   6   ->   3           
j variable (5 values)                     ->   k
xij variables:
Ethnic_minority50 Ethnic_minority100 ... Ethnic_minority2000->Ethnic_minority
-----------------------------------------------------------------------------

. sum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
          id |          5           1           0          1          1
           k |          5         730    805.9156         50       2000
Ethnic_min~y |          5    .7657341    .0568193   .7084086    .842886

. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Ethnic_minority_
> right.dta", replace
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\Ethnic_minority_right.dta saved

. 
. 
. 
. 
. * Analys highed
. foreach year in 2002 2006 2010 {
  2. clear
  3. use "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\highed_`year'_
> temp.dta"
  4. merge 1:m XKOORD_`year' YKOORD_`year' using "\\micro.intra\Projekt\P0624$\P0624_Gem\Po
> litisk Geografi\Data\MergedData\Merged_`year'.dta"
  5. drop _merge
  6. 
. gen parti_low = lower(parti_initial)
  7. gen vald_right = 0
  8. replace vald_right = vald==1 & (parti_low =="c" | parti_low =="m" | parti_low =="k" | 
> parti_low =="f")
  9. 
. foreach k in 50 100 500 1000 2000{
 10. gen RatioLowed_`year'_`k' = 1-RatioHighed_`year'_`k'
 11. bysort kommunkod: egen Lowed_`k' = mean(RatioLowed_`year'_`k')                        
>                           /*Municipality-mean */
 12. bysort kommunkod: egen Lowed_`k'_pol = mean(RatioLowed_`year'_`k') if vald_right==1   
>           /*Ditto for politicians*/
 13. bysort kommunkod: gen Ratio_Lowed_`k'= Lowed_`k'_pol/Lowed_`k'
 14. }
 15. collapse Ratio_Lowed_50 Ratio_Lowed_100 Ratio_Lowed_500 Ratio_Lowed_1000 Ratio_Lowed_2
> 000 
 16. gen year = `year'
 17. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_lowed
> ucation_right_`year'.dta", replace
 18. }

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         6,981,805  (_merge==3)
    -----------------------------------------
(6,930,923 missing values generated)
(6,016 real changes made)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_loweducation_right_2002.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,157,824  (_merge==3)
    -----------------------------------------
(7,106,912 missing values generated)
(6,148 real changes made)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_loweducation_right_2006.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,482,465  (_merge==3)
    -----------------------------------------
(7,430,615 missing values generated)
(5,870 real changes made)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_loweducation_right_2010.dta saved

. 
. use "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_loweducat
> ion_right_2002.dta", clear

. foreach year in 2006 2010 {
  2. append using "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nho
> od_loweducation_right_`year'.dta"
  3. }

. 
. *sum
. *scatter Ratio_Highed_50 Ratio_Highed_500 Ratio_Highed_1000 Ratio_Lowed_2000 year
. *graph export "\\micro.intra\mydocs\mydocs\dahma\my documents\OutBox\k_nearest_Lowed.pdf"
> , as(pdf) 
. collapse Ratio_Lowed_50 Ratio_Lowed_100 Ratio_Lowed_500 Ratio_Lowed_1000 Ratio_Lowed_2000
>  

. ren Ratio_Lowed_50 Lowed50

. ren Ratio_Lowed_100 Lowed100

. ren Ratio_Lowed_500 Lowed500

. ren Ratio_Lowed_1000 Lowed1000

. ren Ratio_Lowed_2000 Lowed2000

. gen id=1

. reshape long Lowed, i(id) j(k)
(j = 50 100 500 1000 2000)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   5           
Number of variables                   6   ->   3           
j variable (5 values)                     ->   k
xij variables:
         Lowed50 Lowed100 ... Lowed2000   ->   Lowed
-----------------------------------------------------------------------------

. sum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
          id |          5           1           0          1          1
           k |          5         730    805.9156         50       2000
       Lowed |          5    .9786138    .0084733   .9681531   .9886422

. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Lowed_right.dta"
> , replace
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Lowed_right.dta
    saved

. 
. 
. 
. 
. * Analys highq
. foreach year in 2002 2006 2010 {
  2. clear
  3. use "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\highq_`year'_t
> emp.dta"
  4. merge 1:m XKOORD_`year' YKOORD_`year' using "\\micro.intra\Projekt\P0624$\P0624_Gem\Po
> litisk Geografi\Data\MergedData\Merged_`year'.dta"
  5. drop _merge
  6. 
. gen parti_low = lower(parti_initial)
  7. gen vald_right = 0
  8. replace vald_right = vald==1 & (parti_low =="c" | parti_low =="m" | parti_low =="k" | 
> parti_low =="f")
  9. 
. foreach k in 50 100 500 1000 2000{
 10. gen RatioLowq_`year'_`k' = 1-RatioHighq_`year'_`k'
 11. bysort kommunkod: egen Lowq_`k' = mean(RatioLowq_`year'_`k')                          
>                           /*Municipality-mean */
 12. bysort kommunkod: egen Lowq_`k'_pol = mean(RatioLowq_`year'_`k') if vald_right==1     
>           /*Ditto for politicians*/
 13. bysort kommunkod: gen Ratio_Lowq_`k'= Lowq_`k'_pol/Lowq_`k'
 14. }
 15. collapse Ratio_Lowq_50 Ratio_Lowq_100 Ratio_Lowq_500 Ratio_Lowq_1000 Ratio_Lowq_2000 
 16. gen year = `year'
 17. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_Lowq_
> right_`year'.dta", replace
 18. }

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         6,981,805  (_merge==3)
    -----------------------------------------
(6,930,923 missing values generated)
(6,016 real changes made)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
(6,975,789 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_Lowq_right_2002.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,157,824  (_merge==3)
    -----------------------------------------
(7,106,912 missing values generated)
(6,148 real changes made)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
(7,151,676 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_Lowq_right_2006.dta saved

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                         7,482,465  (_merge==3)
    -----------------------------------------
(7,430,615 missing values generated)
(5,870 real changes made)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
(7,476,595 missing values generated)
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk
    Geografi\Data\temp\k_nhood_Lowq_right_2010.dta saved

. 
. use "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nhood_Lowq_righ
> t_2002.dta", clear

. foreach year in 2006 2010 {
  2. append using "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\k_nho
> od_Lowq_right_`year'.dta"
  3. }

. *sum
. *scatter Ratio_Highq_50 Ratio_Highq_100 Ratio_Highq_500 Ratio_Highq_1000 Ratio_Lowq_2000 
> year
. *graph export "\\micro.intra\mydocs\mydocs\dahma\my documents\OutBox\k_nearest_Lowq.pdf",
>  as(pdf) 
. 
. collapse Ratio_Lowq_50 Ratio_Lowq_100 Ratio_Lowq_500 Ratio_Lowq_1000 Ratio_Lowq_2000  

. ren Ratio_Lowq_50 Lowq50

. ren Ratio_Lowq_100 Lowq100

. ren Ratio_Lowq_500 Lowq500

. ren Ratio_Lowq_1000 Lowq1000

. ren Ratio_Lowq_2000 Lowq2000

. gen id=1

. reshape long Lowq, i(id) j(k)
(j = 50 100 500 1000 2000)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   5           
Number of variables                   6   ->   3           
j variable (5 values)                     ->   k
xij variables:
            Lowq50 Lowq100 ... Lowq2000   ->   Lowq
-----------------------------------------------------------------------------

. sum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
          id |          5           1           0          1          1
           k |          5         730    805.9156         50       2000
        Lowq |          5    .9726963    .0083039   .9631052    .983237

. save "\\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Lowq_right.dta",
>  replace
file \\micro.intra\projekt\P0624$\P0624_Gem\Politisk Geografi\Data\temp\Lowq_right.dta
    saved

. 
. 
. 
. log close
      name:  <unnamed>
       log:  \\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Results\setup_equipop
> .log
  log type:  text
 closed on:  29 Jun 2023, 17:39:08
-------------------------------------------------------------------------------------------
